package helper;

import java.io.IOException;
import java.io.InputStream;
import java.util.Hashtable;
import java.util.Vector;

public class Configuration
{
	private static final String CONFIGFILE = "properties.ini";
	
	public Hashtable loadConfiguration()
	{
		Hashtable configuration = new Hashtable();
		configuration.put("applicationName", "TrafficTip");
		configuration.put("geoapiurl","http://maps.google.com/maps/geo");
		configuration.put("staticapiurl","http://maps.google.com/staticmap");
		configuration.put("apikey", "ABQIAAAA6n4mnYyhliwGS_KVgdcN9RT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT-lhEiRjMXNAgYQH_f2Yzv12wbQg");

		/*
		String filecontent = this.getFileContent();
		Library lib = new Library();
		
		//Parsear string e construir a hashtable
		String lines[] = lib.split("\n", filecontent);
		
		System.out.println("Size: " + lines);
		*/
		
		return configuration;
	}
	
	private String getFileContent()
	{
		try
		{
			InputStream is = getClass().getResourceAsStream(CONFIGFILE);
		    StringBuffer sb = new StringBuffer();
			int chars;
			
			while((chars = is.read()) != -1)
				sb.append((char) chars);
			
			return sb.toString();
		}
		catch (IOException e) {	e.printStackTrace(); }			
	    
		return null;
	}
}
